package com.feicheng.controller.wx;

import com.alibaba.fastjson.JSONObject;
import com.feicheng.common.result.ResultInfo;
import com.feicheng.common.task.Cache;
import com.feicheng.service.a.FKcService;
import com.feicheng.service.a.FYyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

@RestController("/wx/kc")
@RequestMapping("/wx/kc")
public class KcController {

    @Autowired
    FKcService kcService;

    @Autowired
    FYyService yyService;

    @Autowired
    Cache cache;

    @PostMapping("/page")
    public ResultInfo getKcByPage(@RequestBody JSONObject param) {
        param = kcService.getKcByPage(param);
        return ResultInfo.success(param);
    }

    @PostMapping("/item/page")
    public ResultInfo getKcitemByPage(@RequestBody JSONObject param) {
        param = kcService.getKcitemWithAllByPage(param);
        return ResultInfo.success(param);
    }

    @PostMapping("/lx/tree")
    public ResultInfo getLxTree(@RequestBody JSONObject param) {
        return ResultInfo.success(kcService.getKclxTree());
    }

    @PostMapping("/lx/list")
    public ResultInfo getLxList(@RequestBody JSONObject param) {
        return ResultInfo.success(kcService.getKclxList(param));
    }

    @PostMapping("/kaike")
    public ResultInfo kaike(@RequestBody JSONObject param) {
        param = kcService.kaike(param);
        return ResultInfo.success(param);
    }

    @PostMapping("/info")
    public ResultInfo newKc(@RequestBody JSONObject param) {
        param = kcService.newKc(param);
        return ResultInfo.success(param);
    }

    @GetMapping("/lx/map")
    public ResultInfo getLxMap() {
        return ResultInfo.success(cache.get("kclxs"));
    }

    @PostMapping("/info/get")
    public ResultInfo getKcDetail(@RequestBody JSONObject param) {
        param = kcService.getKc(param);
        return ResultInfo.success(param);
    }

    @PostMapping("/info/put")
    public ResultInfo updateKc(@RequestBody JSONObject param) {
        param = kcService.updateKc(param);
        return ResultInfo.success(param);
    }

    @PostMapping("/cancel")
    public ResultInfo cancelKc(@RequestBody JSONObject param) {
        param = kcService.cancelKc(param);
        return ResultInfo.success(param);
    }
}
